﻿#region << 文 件 说 明 >>

/*----------------------------------------------------------------
// 文件名称：LayoutUcViewBase
// 创 建 者：杨程
// 创建时间：2021/10/13 15:08:47
// 文件版本：V1.0.0
// ===============================================================
// 功能描述：
//
//
//----------------------------------------------------------------*/

#endregion

namespace Vampirewal.Core.WPF.Theme;

/// <summary>
/// 页面布局基类
/// </summary>
public class LayoutUcViewBase : UcViewBase
{
    public UIElement BottomArea { get; set; }

    /// <summary>
    /// 拖动条样式
    /// </summary>
    public ControlTemplate GridSplitterStyle { get; set; }

    static LayoutUcViewBase()
    {
        DefaultStyleKeyProperty.OverrideMetadata(typeof(LayoutUcViewBase), new FrameworkPropertyMetadata(typeof(LayoutUcViewBase)));
    }

    public LayoutUcViewBase()
    {
        //构造函数
        var LayoutUcViewBaseStyle = base.res["LayoutUcViewBase"] as Style;

        this.Style = LayoutUcViewBaseStyle;
    }

    public override void OnApplyTemplate()
    {
        base.OnApplyTemplate();

        #region 拖动条设置

        var GS = this.Template.FindName("gs", this) as GridSplitter;

        #region 自定义GridSplitter模版

        if (GridSplitterStyle != null)
        {
            if (GridSplitterStyle.TargetType == typeof(GridSplitter))
            {
                GS.Template = GridSplitterStyle;
            }
        }

        #endregion

        #endregion

        var bottomarea = this.Template.FindName("BottomArea1", this) as ContentPresenter;
        if (BottomArea == null)
        {
            GS.Visibility = Visibility.Collapsed;
            bottomarea.Visibility = Visibility.Collapsed;
        }
    }
}